<?php

namespace App\Response;

use Hyperf\Utils\Contracts\Jsonable;

class Response implements Jsonable
{
    /**
     * @var int
     */
    public $code;

    /**
     * @var string
     */
    public $msg;

    /**
     * @var array
     */
    public $data = [];


    public function __construct(int $code = 0,string $msg = "ok",array $data = [])
    {
        $this->code = $code;
        $this->msg = $msg;
        $this->data = $data;
    }

    public function __toString() :string
    {
        return json_encode(["code"=>$this->code,"msg"=>$this->msg,"data"=>$this->data],JSON_UNESCAPED_UNICODE);
    }
}